<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/templates/common/taglib.jsp"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%

String diseaseList= (String)request.getAttribute("diseaseList");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>${title }</title>
<link rel="stylesheet"
	href="${basePath}/static/bootstrap/css/bootstrap.css" />
<link href="${basePath}/static/css/basic.css" rel="stylesheet"
	type="text/css">
<link href="${basePath}/static/css/login.css" rel="stylesheet"
	type="text/css">
<link href="${basePath}/static/css1/lyh.css" rel="stylesheet"
	type="text/css">
<link href="${basePath}/static/css/list.css" rel="stylesheet"
	type="text/css">
<link rel="stylesheet" type="text/css"
	href="${basePath}/static/css1/index.css">
<link rel="stylesheet" type="text/css"
	href="${basePath}/static/assert/jquery-ui/jquery-ui.css">
<script type="text/javascript" src="${basePath}/static/js/jquery.min.js"></script>
<script type="text/javascript" src="${basePath}/static/assert/jquery-ui/jquery-ui.js"></script>
<script type="text/javascript"
	src="${basePath}/static/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript"
	src="${basePath}/static/page/jqPaginator/jqPaginator.js"></script>
<script  type="text/javascript" src="${basePath}/static/layer/layer.js"></script>
<link href="${basePath}/static/layer/layer_defined.css" rel="stylesheet" type="text/css">

<style type="text/css">
.btn {
	padding: 6px;
}

.input_select {
	height: 28px;
	width: 57%;
}
</style>
</head>
<body class="bj">
	<!--头部-->
	<%@include file="/WEB-INF/templates/common/header.jsp"%>
	<!------导航条-->
	<%@include file="/WEB-INF/templates/common/navigation.jsp"%>

	<!--内容部分-->
	<div class="list_main lay_out" class="clearfix">
		<div class="list_DH">
			<%@include file="/WEB-INF/templates/common/queryNav.jsp"%>
		</div>
		<div class="list_NR">
			<div class="loc">
				<h3 style="margin:0">临床检索</h3>
			</div>
			<div class="list_con_table" style="margin-top:-10px">
				<div class="search_table">
					<ul>
						<li class="Label_1" style="width: 10%">姓名：&nbsp;</li>
						<li class="Label_2" style="width: 23%"><input
							class="input_box" type="text" name='' id='patientName' value='' /></li>
						<li class="Label_1">ID号：&nbsp;</li>
						<li class="Label_2"><input class="input_box" type="text"
							name='' id='mrId' value='' /></li>
						<li class="Label_1">身份证：&nbsp;</li>
						<li class="Label_2"><input class="input_box" type="text"
							name='' id='idNumber' value='' /></li>
						<li class="Label_1" style="width: 10%">出院日期：&nbsp;</li>
						<li class="Label_2" style="width: 23%">
						<input
							class="input_box" style="width: 44%" type="text"
							onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" name=''
							id='outHospitalStartTime' value='' />&nbsp;-&nbsp;<input
							class="input_box" style="width: 44%" type="text"
							onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" name=''
							id='outHospitalEndTime' value='' /></li>
						<%-- <li class="Label_1">出院科室：&nbsp;</li>
						<li class="Label_2 field">
						<input style="width: 94%; height: 28px" class="input_box" type="hidden"
							name='' id="outHospitalOfficeName" value='${officeName}' readonly="readonly"/>
						 <select id="outHospitalOfficeName" style="width:95%;height: 28px; text-align: left;text-indent: 5px;line-height: 28px; background: #fff;border: #e3e5e4 solid 1px;">
								<option value=''>-------请选择-------</option> 
								<c:forEach items="${basicInfoList.outOfficeList}" var="outOffice">
									<option value='${outOffice.name}'>${outOffice.name}</option> 
								</c:forEach>
						</select>
						</li>
		 --%>
						
						<li class="Label_1">病案号：&nbsp;</li>
						<li class="Label_2"><input style="width: 94%; height: 28px" class="input_box" type="text"
							name='' id='onlyId' value='' /></li>
			
						
						
						</li>
						

						
						<li class="Label_5"><a onclick="init(1,10)">查询</a></li>
					</ul>
				</div>
				<table style="width:100%; float: left; border-collapse: collapse;"
					cellpadding="0" cellspacing="0">
					<tr>
						<td class="tdLabel_4">ID号</td>
						<td class="tdLabel_4">姓名</td>
						<td class="tdLabel_4">身份证</td>
						<td class="tdLabel_4">出院科室</td>
						<td class="tdLabel_4">出院时间</td>
						<td class="tdLabel_4">住院次数</td>
						<td class="tdLabel_4">操作</td>
					</tr>
					<tr id="loading" style="height:50px;display:none">
	       				<td colspan="6" align="center" ><img src="${basePath}/static/layer/skin/default/loading-2.gif"></td>
				    </tr>
					<tbody id="tbody"></tbody>
				</table>
				
				<div class="pageList">
            <ul class="pagination clearfix" id="page_plus"></ul>
            <div class="pagination">
                <div>总共：<b id="totalPage">0</b> 条信息    当前页是第 <b id="currentPage">0/0</b>　页</div>
            </div>
        </div>

			</div>
		</div>
	</div>	
		<!------页脚部分--------->
		<%@include file="/WEB-INF/templates/common/footer.jsp"%>

		<!--JS部分-->
		<script type="text/javascript">
			function init(pageNo, pageSize) {

				var patientName = $("#patientName").val();
				var onlyId = $("#onlyId").val();
				var mrId = $("#mrId").val();
				var idNumber = $("#idNumber").val();
				var outHospitalStartTime = $("#outHospitalStartTime").val();
				var outHospitalEndTime = $("#outHospitalEndTime").val();
			 	var outHospitalOfficeName = $("#outHospitalOfficeName").val();
		
			 	//alert(patientName+"--"+onlyId+"--"+mrId+"--"+idNumber+"--"+outHospitalStartTime+"--"+outHospitalEndTime+"--"+visitNumber+"--"+outHospitalTypeName+"--"+outHospitalOfficeName+"--"+inHospitalStateName+"--"+operationName+"--"+operationRadio+"--"+paymentTypeName+"--"+professionName+"--"+diseaseName+"--"+diseaseRadio+"--"+startAge+"--"+endAge+"=="+marraigeName);
			
				if((patientName=="" || patientName==null) && (onlyId=="" || onlyId==null) && (idNumber=="" || idNumber==null)&& (outHospitalStartTime=="" || outHospitalStartTime==null)&& (outHospitalEndTime=="" || outHospitalEndTime==null)&& (mrId=="" || mrId==null) 
					&& (outHospitalOfficeName=="" || outHospitalOfficeName==null) 
					 ){
					layer.alert("请至少输入一个查询条件!",{icon:5});
					return;
				}
			
				jQuery.support.cors = true;
				
					$.ajax({
							type : 'post',
							url : "${basePath}/retrieval/getMedicalSpecialRecord",
							data : {
								patientName : patientName,
								onlyId : onlyId,
								mrId : mrId,
								idNumber : idNumber,
								outHospitalStartTime : outHospitalStartTime,
								outHospitalEndTime : outHospitalEndTime,
								specialIndication:null,
								outHospitalOfficeName : outHospitalOfficeName,
								pageNo:pageNo,
								pageSize:pageSize
							},
							beforeSend:function(){
								$("#tbody").html("");
								$("#loading").show();
							},
							success : function(data) {
								$("#loading").hide();
		
								if (data.success) {
									var hospitalNotes = data.data.specialMedicalList;
									var totalCount = data.data.totalCount;
									var len = hospitalNotes.length;
									if (len > 0) {
										var html = '';
										for (var i = 0; i < len; i++) {
											var obj = hospitalNotes[i];
											html += "<tr>"
													+ "  <td class='tdLabel_5'>"
													+ (obj.mrId == undefined ? ''
															: obj.mrId)
													+ "</td>"
													+ "  <td class='tdLabel_5'>"
													+ (obj.NAME == undefined ? ''
															: obj.NAME)
													+ "</td>"
													+ "  <td class='tdLabel_5'>"
													+ (obj.idNumber == undefined ? ''
															: obj.idNumber)
													+ "</td>"
													+ "  <td class='tdLabel_5'>"
													+ (obj.officeName == undefined ? ''
															: obj.officeName)
													+ "</td>"
													+ "  <td class='tdLabel_5'>"
													+ (obj.outHospitalDate == undefined ? ''
															: obj.outHospitalDate)
													+ "</td>"
													+ "  <td class='tdLabel_5'>"
													+ (obj.visitNumber == undefined ? ''
															: obj.visitNumber)
													+ "</td>"
													+ "  <td class='tdLabel_5'>"
													+" <a class='int' target='_blank' href='${corePath}/medical_record/print?visitGuid="
												    + obj.firstGuid
													+ "'>查看病案</a>"
													+"</td></tr>";

										}
										page(pageNo, totalCount)
										$("#tbody").html("").html(html);
									} else {
										layer.alert("数据为空!",{icon:5});
										$("#tbody").html("");
									}
								}
							}
						})
			}

			function page(currentPage, totalCounts) {
				var pageSize = 10;
				var visiblePages = 5;
				var totalPages = Math.ceil(totalCounts / pageSize);
				$('#page_plus')
						.jqPaginator(
								{

									totalCounts : totalCounts,
									pageSize : pageSize,
									visiblePages : visiblePages,
									currentPage : currentPage,

									first : '<li class="first"><a href="javascript:void(0);">首页</a></li>',
									prev : '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
									next : '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
									last : '<li class="last"><a href="javascript:void(0);">末页</a></li>',
									page : '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
									onPageChange : function(num, type) {

										if (type != 'init') {

											init(num, pageSize);
										}

										$("#totalPage").html(totalCounts);
										$("#currentPage").html(
												num + "/" + totalPages);
									}
								});

			}

		
		</script>
</body>
</html>

<%-- <%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/templates/common/taglib.jsp"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%

String diseaseList= (String)request.getAttribute("diseaseList");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>${title }</title>
<link rel="stylesheet"
	href="${basePath}/static/bootstrap/css/bootstrap.css" />
<link href="${basePath}/static/css/basic.css" rel="stylesheet"
	type="text/css">
<link href="${basePath}/static/css/login.css" rel="stylesheet"
	type="text/css">
<link href="${basePath}/static/css1/lyh.css" rel="stylesheet"
	type="text/css">
<link href="${basePath}/static/css/list.css" rel="stylesheet"
	type="text/css">
<link rel="stylesheet" type="text/css"
	href="${basePath}/static/css1/index.css">
<link rel="stylesheet" type="text/css"
	href="${basePath}/static/assert/jquery-ui/jquery-ui.css">
<script type="text/javascript" src="${basePath}/static/js/jquery.min.js"></script>
<script type="text/javascript" src="${basePath}/static/assert/jquery-ui/jquery-ui.js"></script>
<script type="text/javascript"
	src="${basePath}/static/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript"
	src="${basePath}/static/page/jqPaginator/jqPaginator.js"></script>
<script  type="text/javascript" src="${basePath}/static/layer/layer.js"></script>
<link href="${basePath}/static/layer/layer_defined.css" rel="stylesheet" type="text/css">

<style type="text/css">
.btn {
	padding: 6px;
}

.input_select {
	height: 28px;
	width: 57%;
}
</style>
</head>
<body class="bj">
	<!--头部-->
	<%@include file="/WEB-INF/templates/common/header.jsp"%>
	<!------导航条-->
	<%@include file="/WEB-INF/templates/common/navigation.jsp"%>

	<!--内容部分-->
	<div class="list_main lay_out" class="clearfix">
		<div class="list_DH">
			<%@include file="/WEB-INF/templates/common/queryNav.jsp"%>
		</div>
		<div class="list_NR">
			<div class="loc">
				<h3 style="margin:0">临床检索</h3>
			</div>
			<div class="list_con_table" style="margin-top:-10px">
				<div class="search_table">
					<ul>
						<li class="Label_1" style="width: 10%">姓名：&nbsp;</li>
						<li class="Label_2" style="width: 23%"><input
							class="input_box" type="text" name='' id='patientName' value='' /></li>
						<li class="Label_1">ID号：&nbsp;</li>
						<li class="Label_2"><input class="input_box" type="text"
							name='' id='mrId' value='' /></li>
						<li class="Label_1">身份证：&nbsp;</li>
						<li class="Label_2"><input class="input_box" type="text"
							name='' id='idNumber' value='' /></li>
						<li class="Label_1" style="width: 10%">出院日期：&nbsp;</li>
						<li class="Label_2" style="width: 23%">
						<input
							class="input_box" style="width: 44%" type="text"
							onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" name=''
							id='outHospitalStartTime' value='' />&nbsp;-&nbsp;<input
							class="input_box" style="width: 44%" type="text"
							onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" name=''
							id='outHospitalEndTime' value='' /></li>
						<li class="Label_1">住院次数：&nbsp;</li>
						<li class="Label_2">
							<input style="width: 94%; height: 28px" class="input_box" type="text"
							name='' id='visitNumber' value='' />
		
						</li>
						
						<li class="Label_1">病案号：&nbsp;</li>
						<li class="Label_2"><input style="width: 94%; height: 28px" class="input_box" type="text"
							name='' id='onlyId' value='' /></li>
			
						
						<li class="Label_1" style="width: 10%">离院方式：&nbsp;</li>
						<li class="Label_2" style="width: 23%">
							
							<select id="outHospitalTypeName" style="width:95%;height: 28px; text-align: left;text-indent: 5px;line-height: 28px; background: #fff;border: #e3e5e4 solid 1px;">
								<option value=''>-------请选择-------</option> 
								<c:forEach items="${basicInfoList.outHospitalTypeList}" var="outHospitalType">
									<option value='${outHospitalType.name}'>${outHospitalType.name}</option> 
								</c:forEach>
							</select>	
						</li>
						<li class="Label_1">出院科室：&nbsp;</li>
						<li class="Label_2 field">
							<input style="width: 94%; height: 28px" class="input_box" type="text"
							name='' id="outHospitalOfficeName" value='${officeName}' readonly="readonly"/>
						<select id="outHospitalOfficeName" style="width:95%;height: 28px; text-align: left;text-indent: 5px;line-height: 28px; background: #fff;border: #e3e5e4 solid 1px;">
								<option value=''>-------请选择-------</option> 
								<c:forEach items="${basicInfoList.outOfficeList}" var="outOffice">
									<option value='${outOffice.name}'>${outOffice.name}</option> 
								</c:forEach>
						</select>	
		
						</li>
						<li class="Label_1">入院状态：&nbsp;</li>
						<li class="Label_2">
						<select id="inHospitalStateName" style="width:95%;height: 28px; text-align: left;text-indent: 5px;line-height: 28px; background: #fff;border: #e3e5e4 solid 1px;">
								<option value=''>-------请选择-------</option> 
								<c:forEach items="${basicInfoList.inHospitalStateList}" var="inHospitalState">
									<option value='${inHospitalState.name}'>${inHospitalState.name}</option> 
								</c:forEach>
						</select>	
						</li>
							
						<li class="Label_1" style="width: 10%">手术名称：&nbsp;</li>
						<li class="Label_2" style="width: 23% ;text-align:left">&nbsp;<input
                          class="input_box" type="text" style="width:95%;" name='' id='diag_operation_name' value='' />
	                    </li>
							
						<li class="Label_1">付费方式：&nbsp;</li>
						<li class="Label_2">
							<select id="paymentTypeName" style="width:95%;height: 28px; text-align: left;text-indent: 5px;line-height: 28px; background: #fff;border: #e3e5e4 solid 1px;">
								<option value=''>-------请选择-------</option> 
								<c:forEach items="${basicInfoList.paymentTypeList}" var="paymentType">
									<option value='${paymentType.name}'>${paymentType.name}</option> 
								</c:forEach>
						</select>	
						</li>
						<li class="Label_1">职业：&nbsp;</li>
						<li class="Label_2">
						<select id="professionName" style="width:95%;height: 28px; text-align: left;text-indent: 5px;line-height: 28px; background: #fff;border: #e3e5e4 solid 1px;">
								<option value=''>-------请选择-------</option> 
								<c:forEach items="${basicInfoList.professionList}" var="profession">
									<option value='${profession.name}'>${profession.name}</option> 
								</c:forEach>
						</select>	
							
						</li>
						
						<li class="Label_1" style="width: 10%">疾病名称：&nbsp;</li>

						<li class="Label_2" style="width: 23% ;">
						<input 
							class="input_box" type="text" style="width:95%;" name='' id='diag_disease_name' value='' />
							
						</li>
						<li class="Label_1">年龄：&nbsp;</li>
						<li class="Label_2">
							<input id="startAge"
							class="input_box" style="width: 44%" type="text"
							 name=''
							 value='' />&nbsp;-&nbsp;<input
							class="input_box" style="width: 44%" type="text"
							 name='' id="endAge"
							 value='' />
						</li>
						<li class="Label_1">婚姻状况：&nbsp;</li>
						<li class="Label_2">
						<select id="marraigeName" style="width:95%;height: 28px; text-align: left;text-indent: 5px;line-height: 28px; background: #fff;border: #e3e5e4 solid 1px;">
								<option value=''>-------请选择-------</option> 
								<c:forEach items="${basicInfoList.marriageList}" var="marriage">
									<option value='${marriage.name}'>${marriage.name}</option> 
								</c:forEach>
						</select>	
					 </li>
						
						

						
						<li class="Label_5"><a onclick="init(1,10)">查询</a></li>
					</ul>
				</div>
				<table style="width: 934px; float: left; border-collapse: collapse;"
					cellpadding="0" cellspacing="0">
					<tr>
						<td class="tdLabel_4">ID号</td>
						<td class="tdLabel_4">姓名</td>
						<td class="tdLabel_4">身份证</td>
						<td class="tdLabel_4">出院科室</td>
						<td class="tdLabel_4">出院时间</td>
						<td class="tdLabel_4">离院方式</td>
						<td class="tdLabel_4">操作</td>
					</tr>
					<tr id="loading" style="height:50px;display:none">
	       				<td colspan="6" align="center" ><img src="${basePath}/static/layer/skin/default/loading-2.gif"></td>
				    </tr>
					<tbody id="tbody"></tbody>
				</table>
				
				<div class="pageList">
            <ul class="pagination clearfix" id="page_plus"></ul>
            <div class="pagination">
                <div>总共：<b id="totalPage">0</b> 条信息    当前页是第 <b id="currentPage">0/0</b>　页</div>
            </div>
        </div>

			</div>
		</div>
	</div>	
		<!------页脚部分--------->
		<%@include file="/WEB-INF/templates/common/footer.jsp"%>

		<!--JS部分-->
		<script type="text/javascript">
			function init(pageNo, pageSize) {

				var patientName = $("#patientName").val();
				var onlyId = $("#onlyId").val();
				var mrId = $("#mrId").val();
				var idNumber = $("#idNumber").val();
				var outHospitalStartTime = $("#outHospitalStartTime").val();
				var outHospitalEndTime = $("#outHospitalEndTime").val();
				var visitNumber=$("#visitNumber").val();
				var outHospitalTypeName = $("#outHospitalTypeName").val();
			 	var outHospitalOfficeName = $("#outHospitalOfficeName").val();
				var inHospitalStateName = $("#inHospitalStateName").val();
			 	var operationName=$("#diag_operation_name").val();
				//var operationRadio=$('input:radio[name="operationRadio"]:checked').val();
			 	var paymentTypeName = $("#paymentTypeName").val();
				var professionName = $("#professionName").val();
			 	var diseaseName = $("#diag_disease_name").val();
			 	//var diseaseRadio=$('input:radio[name="diseaseRadio"]:checked').val();
				var startAge = $("#startAge").val();
				var endAge = $("#endAge").val();
				var marraigeName=$("#marraigeName").val();
			 	//alert(patientName+"--"+onlyId+"--"+mrId+"--"+idNumber+"--"+outHospitalStartTime+"--"+outHospitalEndTime+"--"+visitNumber+"--"+outHospitalTypeName+"--"+outHospitalOfficeName+"--"+inHospitalStateName+"--"+operationName+"--"+operationRadio+"--"+paymentTypeName+"--"+professionName+"--"+diseaseName+"--"+diseaseRadio+"--"+startAge+"--"+endAge+"=="+marraigeName);
			
				if((patientName=="" || patientName==null) && (onlyId=="" || onlyId==null) && (idNumber=="" || idNumber==null)&& (outHospitalStartTime=="" || outHospitalStartTime==null)&& (outHospitalEndTime=="" || outHospitalEndTime==null)&& (mrId=="" || mrId==null) && (visitNumber=="" || visitNumber==null)
					&&(outHospitalTypeName=="" || outHospitalTypeName==null) && (outHospitalOfficeName=="" || outHospitalOfficeName==null) && (inHospitalStateName=="" || inHospitalStateName==null) && (operationName=="" || operationName==null) && (paymentTypeName=="" || paymentTypeName==null) && (professionName=="" || professionName==null)
					&&(diseaseName==null || diseaseName=='')&&(startAge==null || startAge=='')&&(endAge==null || endAge=='') && (marraigeName==null || marraigeName=='') ){
					layer.alert("请至少输入一个查询条件!",{icon:5});
					return;
				}
				
/* 				console.log("name=" + name + "---sexId=" + only + "---idCard="
						+ idCard + "--mrId=" + mrId + "--outHospitalStartTime="
						+ outHospitalStartTime + "---outHospitalEndTime="
						+ outHospitalEndTime + "---outHospitalOfficeId="
						+ outHospitalOfficeId + "---outHospitalTypeIds="
						+ outHospitalTypeIds); */
				jQuery.support.cors = true;
				
					$.ajax({
							type : 'post',
							url : "${basePath}/retrieval/getMedicalRecordRetrieval",
							data : {
								patientName : patientName,
								onlyId : onlyId,
								mrId : mrId,
								idNumber : idNumber,
								outHospitalStartTime : outHospitalStartTime,
								outHospitalEndTime : outHospitalEndTime,
								visitNumber : visitNumber,
								outHospitalTypeName : outHospitalTypeName,
								outHospitalOfficeName : outHospitalOfficeName,
								inHospitalStateName : inHospitalStateName,
								operationName : operationName,
								//operationRadio : operationRadio,
								paymentTypeName : paymentTypeName,
								professionName : professionName,
								diseaseName : diseaseName,
								//diseaseRadio:diseaseRadio,
								startAge : startAge,
								endAge : endAge,
								marraigeName : marraigeName,
								pageNo:pageNo,
								pageSize:pageSize
							},
							beforeSend:function(){
								$("#tbody").html("");
								$("#loading").show();
							},
							success : function(data) {
								$("#loading").hide();
								console.log(data);
							
								if (data.success) {
									var hospitalNotes = data.data.medrecordJsonList;
									var totalCount = data.data.totalCount;
									var len = hospitalNotes.length;
									if (len > 0) {
										var html = '';
										for (var i = 0; i < len; i++) {
											var obj = hospitalNotes[i];
											html += "<tr>"
													+ "  <td class='tdLabel_5'>"
													+ (obj.mrId == undefined ? ''
															: obj.mrId)
													+ "</td>"
													+ "  <td class='tdLabel_5'>"
													+ (obj.patientName == undefined ? ''
															: obj.patientName)
													+ "</td>"
													+ "  <td class='tdLabel_5'>"
													+ (obj.idNumber == undefined ? ''
															: obj.idNumber)
													+ "</td>"
													+ "  <td class='tdLabel_5'>"
													+ (obj.outDeptName == undefined ? ''
															: obj.outDeptName)
													+ "</td>"
													+ "  <td class='tdLabel_5'>"
													+ (obj.outHospitalDateTime == undefined ? ''
															: obj.outHospitalDateTime)
													+ "</td>"
													+ "  <td class='tdLabel_5'>"
													+ (obj.outHospitalTypeName == undefined ? ''
															: obj.outHospitalTypeName)
													+ "</td>"
													+ " <td class='tdLabel_5'><a class='int' target='_blank' href='${corePath}/medical_record/print?visitGuid="+obj.visitGuid+"'>查看病案</a>"
													/* + "  <td class='tdLabel_5'><a class='int' target='_blank' href='${corePath}/medrecord/paginationMarkMedrecordImages?firstGuid="
													+ obj.visitGuid
													+ "'>图像</a>&nbsp;&nbsp;<a class='int' target='_blank' href='${corePath}/medical_record/searchHomePageIndexForm?visitGuid=" */
													
													+ "</td>" + "</tr>";

										}
										page(pageNo, totalCount)
										$("#tbody").html("").html(html);
									} else {
										layer.alert("数据为空!",{icon:5});
										$("#tbody").html("");
									}
								}
							}
						})
			}

			function page(currentPage, totalCounts) {
				var pageSize = 10;
				var visiblePages = 5;
				var totalPages = Math.ceil(totalCounts / pageSize);
				$('#page_plus')
						.jqPaginator(
								{

									totalCounts : totalCounts,
									pageSize : pageSize,
									visiblePages : visiblePages,
									currentPage : currentPage,

									first : '<li class="first"><a href="javascript:void(0);">首页</a></li>',
									prev : '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
									next : '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
									last : '<li class="last"><a href="javascript:void(0);">末页</a></li>',
									page : '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
									onPageChange : function(num, type) {

										if (type != 'init') {

											init(num, pageSize);
										}

										$("#totalPage").html(totalCounts);
										$("#currentPage").html(
												num + "/" + totalPages);
									}
								});

			}

			//获取checkbox值
			function getFormVals(name) {
				var arr = [];
				$("input[type='checkbox'][name='" + name + "']:checked").each(
						function() {
							arr.push($(this).val());

						});
				return arr.toString();
			}

			function selectAll() {
				$('input[name="outHospitalType"]').each(function() {
					//此处如果用attr，会出现第三次失效的情况  
					$(this).prop("checked", true);
				});
			}

			function disableAll() {
				$('input[name="outHospitalType"]').each(function() {
					//此处如果用attr，会出现第三次失效的情况  
					$(this).prop("checked", false);
				});
			}

			function getRadioValues(className) {
				var arr = [];
				$("." + className + "").each(function() {
					if ($(this).is(':checked')) {
						arr.push($(this).val());
					}
				})
				return arr.toString();
			}
			
			
			  $(function() {
				  
				  $( "#diag_operation_name" ).autocomplete({
				      minLength: 0,
				      source: function( request, response ) {
				   
				    	 var queryName = request.term;
				    	 $( "#diag_operation_name" ).val(queryName);
				    	 if(queryName!=null && queryName!=''){
				    		 $.ajax({
						    		type:"post",
						    		url: "${basePath}/basicInfo/ajaxOperationJson",
						    		dataType: "json",
						    		data:{
										queryName: request.term
									},
									success: function( data ) {
										response( $.map( data, function( item ) {
											return {
												name:item.name,
												code:item.code
											}
										}));
									}
						    	 }); 
				    	 }
				    	
				    	 
				    	
				      },
				     /*  focus: function( event, ui ) {
				        $( "#diag_operation_name" ).val( ui.item.name );
				        return false;
				      }, */
				      select: function( event, ui ) {
				        $( "#diag_operation_name" ).val( ui.item.name );
				      
				 
				        return false;
				      }
				    })
				    .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
				      return $( "<li>" )
				        .append( "<a>" + item.name +"</a>" )
				        .appendTo( ul );
				    };
				
		
				  
				  
				  
				   
			
				 
				    $( "#diag_disease_name" ).autocomplete({
				      minLength: 0,
				      source: function( request, response ) {
				   
				    	 var queryName = request.term;
				    	 $( "#diag_disease_name" ).val(queryName);
				    	 if(queryName!=null && queryName!=''){
				    		 $.ajax({
						    		type:"post",
						    		url: "${basePath}/basicInfo/ajaxDiagDieaseJson",
						    		dataType: "json",
						    		data:{
										queryName: request.term
									},
									success: function( data ) {
										response( $.map( data, function( item ) {
											return {
												name:item.name,
												code:item.code
											}
										}));
									}
						    	 }); 
				    	 }
				    	
				    	 
				    	
				      },
				
				      select: function( event, ui ) {
				        $( "#diag_disease_name" ).val( ui.item.name );
				      
				 
				        return false;
				      }
				    })
				    .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
				      return $( "<li>" )
				        .append( "<a>" + item.name +"</a>" )
				        .appendTo( ul );
				    };
				  });
		</script>
</body>
</html> --%>
<%-- <%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/templates/common/taglib.jsp"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>胡桃健康</title>
    <link rel="stylesheet" href="${basePath}/static/bootstrap/css/bootstrap.css"/>
    <link href="${basePath}/static/css/basic.css" rel="stylesheet" type="text/css">
    <link href="${basePath}/static/css/login.css" rel="stylesheet" type="text/css">
    <link href="${basePath}/static/css/list.css" rel="stylesheet" type="text/css">
    
	<link rel="stylesheet" type="text/css" href="${basePath}/static/css1/index.css">
    <script type="text/javascript" src="${basePath}/static/js/jquery.min.js"></script>
	<script type="text/javascript" src="${basePath}/static/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="${basePath}/static/page/jqPaginator/jqPaginator.js"></script>
	<script  type="text/javascript" src="${basePath}/static/layer/layer.js"></script>
    <link href="${basePath}/static/layer/layer_defined.css" rel="stylesheet" type="text/css">
    <style type="text/css">
        .Label_1{
         width:8%;
        }
        .Label_2{
         text-align:left;
         padding-left:3px;
        }
        .check_cl {
		    width: 15px;  
		}
    	.input_select{
    	height:28px;
    	width:57%;
    	}
    	
    	/* 查询显示框 */
    	 .td_box{
    	 position:relative;
    	} 
    	.search_tip{
    	 position:absolute;
    	 top:0px;
    	 width:398px;
    	 height:215px;
    	 background:#f8f8f8;
    	 border:1px dashed #ccc;
    	 display:none;
    	}
    	.l_left{
    	float:left;
    	}
    	.r_right{
    	 float:right;
    	}
    	.search_tip_left,.search_tip_right{
    	 width:177px;
    	 height:182px;
    	}
    	.search_tip_left p,.search_tip_right p{
    	 height:40px;
    	 line-height:40px;
    	 margin:0;
    	}
    	.search_tip_left p span,.search_tip_right p span{
    	 color:#006633;
    	}
    	.search_tip_input{
    	  width:100px;
    	  line-height:25px;
    	}
    	.search_tip_left ul,.search_tip_right ul{
    	  height:142px;
    	  background:#fff;
          overflow-y:auto;
    	}
    	.search_tip_left ul li,.search_tip_right ul li{
    	  line-height:30px;
    	  padding-left:3px;
    	  color:#006633;
    	}
    	.mouseOverCs{
    	 background-color:#eee;
    	}
    	.select_color{
    	 background-color:#EDD1A6;
    	}
    	.search_tip_mid{
    	 width:40px;
    	 padding-top:80px;
    	}
    	span.add_btn,span.del_btn{
    	display:block;
    	margin-bottom:10px;
    	text-align:center;
    	background:#ccc;
    	cursor: pointer;
    	}
    	.search_tip_footer{
    	 height:33px;
    	}
    	
    	.search_tip_footer a{
    	 line-height:33px;
    	 margin-right:10px;
    	 color:#337ab7;
    	}
    </style>
</head>
<body>
<!--头部-->
	<%@include file="/WEB-INF/templates/common/header.jsp"%>
	<!------导航条-->
	<%@include file="/WEB-INF/templates/common/navigation.jsp"%>

<!--内容部分-->
<div class="list_main lay_out" class="clearfix">
    <div class="list_DH">
        <%@include file="/WEB-INF/templates/common/queryNav.jsp"%>
    </div>
    <div class="list_NR">
  		<div class="loc" style="margin-bottom:10px;">
  			 <h3>临床检索</h3>
  		</div>
	    <form action="#" style="height:auto;border:1px solid #e3e5e4;margin-bottom:10px;" method="post" target="_blank"
		name="form1">
		<table>
				<tr>
					<td class="Label_1" align="left" width="8%">出院日期</td>
					<td class="Label_2">
						<input type="text" name="outHospitalStartTime" id="outHospitalStartTime"
							value=""
							onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" class="Wdate input input_box_date"
							style="width: 120px" />
						-
						<input type="text" name="outHospitalEndTime" id="outHospitalEndTime"
							value=""
							onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" class="Wdate input input_box_date"
							style="width: 120px" />
						
					</td>
					<td class="Label_1" width="8%">出院科室<input type="hidden" id="ksmcInfo"></td>
					<td colspan="4" class="Label_2">
						<select name="officeId" id="officeId" style="width:45%;height:28px">
							<option value="">请选择科室</option>
							<c:forEach items="${hospitalOfficeList}" var="hospitalOffice">
								<option value="${hospitalOffice.id}">${hospitalOffice.name}</option>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<td class="Label_1">手术名称</td>
					<td class="Label_2 td_box">
					     <input type="text" name="operationName" class="input input_box search_input" style="width:45%">
						 <div class="search_tip">
						        <div class="search_tip_header clearfix">
						           <div class="search_tip_left l_left">
						           <p><span>手术索引：</span><input type="text" class="search_tip_input"></p>
						           <ul id="operationList" class="search_tip_list">
							       </ul>
						         </div>
						         <div class="search_tip_mid l_left">
						          <span class="add_btn" onclick="addlist(event)">新增</span>
						          <span class="del_btn" onclick="dellist(event)">删除</span>
						         </div>
						         <div class="search_tip_right l_left">
						           <p><span>已选择手术：</span></p>
						           <ul class="search_tip_choicelist">
							           <!--  <li>01-疾病名称疾病名称疾病名称</li> -->
						           </ul>
						         </div>
						        </div>
						        <div class="search_tip_footer">
						            <div class="r_right"><a onclick="btn_finish(event)">确认</a><a onclick="btn_close(event)">关闭</a>&nbsp;&nbsp;&nbsp;&nbsp;</div>
						        </div> 
						    </div>  
					</td>
					<td class="Label_1">疾病名称</td>
					<td class="Label_2 td_box">
						    <input type="text" name="diseaseName" class="input input_box search_input" id="search_input2" style="width:45%">
						    <div class="search_tip">
						        <div class="search_tip_header clearfix">
						           <div class="search_tip_left l_left">
						           <p><span>疾病索引：</span><input type="text" class="search_tip_input" id="search_tip_input"></p>
						           <ul id="diseaseList" class="search_tip_list">
							           <!--  <li class="" onclick="click_(event)" code="01">01-疾病名称疾病名称疾病名称</li>
							            <li class="" onclick="click_(event)" code="01">02-疾病名称疾病名称疾病名称</li>
							            <li class="" onclick="click_(event)" code="01">03-疾病名称疾病名称疾病名称</li> -->
						           </ul>
						         </div>
						         <div class="search_tip_mid l_left">
						          <span class="add_btn" onclick="addlist(event)">新增</span>
						          <span class="del_btn" onclick="dellist(event)">删除</span>
						         </div>
						         <div class="search_tip_right l_left">
						           <p><span>已选择疾病：</span></p>
						           <ul class="search_tip_choicelist">
							           <!--  <li>01-疾病名称疾病名称疾病名称</li> -->
						           </ul>
						         </div>
						        </div>
						        <div class="search_tip_footer">
						            <div class="r_right"><a onclick="btn_finish(event)">确认</a><a onclick="btn_close(event)">关闭</a>&nbsp;&nbsp;&nbsp;&nbsp;</div>
						        </div> 
						    </div>
					</td>	
				 </tr>		
				 <tr>
						<td align="left" class="Label_1">入院病情</td>
						<td class="Label_2">
						<select id="inHospitalStatus" style="width:45%;height:28px">
							<option value="">请选择入院状况</option>
							<c:forEach items="${inHospitalStateList}" var="inHospitalState">
								<option value="${inHospitalState.id}">${inHospitalState.name}</option>
							</c:forEach>
						</td>
					    <td align="left" class="Label_1">诊断类型</td>
						<td class="Label_2">
							<select name="diagnoseType" id="diagnoseType" style="width:45%;height:28px">
							<option value="">请选择诊断类型</option>
							<c:forEach items="${diagnoseTypeList}" var="diagnoseType">
								<option value="${diagnoseType.id}">${diagnoseType.name}</option>
							</c:forEach>
						</select>
						</td>
				</tr>
				<tr>
					<td align="left" class=" Label_1">离院方式</td>
					<td colspan="5" class=" Label_2">
						<c:forEach items="${outHospitalTypeList}" var="outHospitalType">
    						 <label><input type="checkbox" class="check_cl"  name='outHospitalType' id='' value='${outHospitalType.id}' />${outHospitalType.name }</label>
   					  </c:forEach>
    				 </br>
    				 <input class="btn_qx" type="button"  name='' onclick="selectAll()" value='全选' />
    				 <input class="btn_qx" type="button"  name='' onclick="disableAll()" value='取消' />
					</td>
				</tr>
                <tr>
				<td class="Label_5" style="text-align:right;background:#e3e5e4" colspan="6">	
					<a onclick="medicalRetire(1,10)">查询</a>
				</td>
				</tr>
		</table>
	</form>
	 <table id="resultTable"  class="Search_tableList" cellpadding="0" cellspacing="0">
      <tr>
      <td class="tdLabel_4">ID号</td>
      <td class="tdLabel_4">姓名</td>
      <td class="tdLabel_4">身份证</td>
      <td class="tdLabel_4">出院时间</td>
      <td class="tdLabel_4">出院科室</td>
      <td class="tdLabel_4">离院方式</td>
      <td class="tdLabel_4">浏览</td>
      </tr>
      <tr id="loading" style="height:50px;display:none">
	       <td colspan="6" align="center" ><img src="${basePath}/static/layer/skin/default/loading-2.gif"></td>
	  </tr>
      <tbody id="tbody">
      </tbody>
   </table>
   <div class="pageList">
            <ul class="pagination clearfix" id="page_plus"></ul>
            <div class="pagination">
                <div>总共：<b id="totalPage">0</b> 条信息    当前页是第 <b id="currentPage">0/0</b>　页</div>
            </div>
    </div>
</div>
</div>
<!------页脚部分--------->
<%@include file="/WEB-INF/templates/common/footer.jsp"%>

 <!--JS部分-->
<script type="text/javascript">
	$(function(){
		//疾病名称及手术名称表单获取焦点事件
		$(".search_input").focus(function(){
			$(this).next(".search_tip").show();
		}); 
		
		/* 弹框查询事件 */
	    $(".search_tip_input").on('input',function(){
	    	 var _this=this;
	    	 //每次change清空已选择的列表
	    	 $(_this).closest('.search_tip').find(".search_tip_choicelist").html("");
	    	 var url="";
	    	 //判断是手术还是疾病索引
	    	if($(_this).prev('span').text().indexOf('手术')>-1){
	    		url="${basePath}/retrieval/getOperationByCodeAndName";
	    	}else if($(_this).prev('span').text().indexOf('疾病')>-1){
	    		url="${basePath}/retrieval/getDiseaseByCodeAndName";
	    	}
	    	 
	    	var name=$(_this).val();
	 		$.ajax({
	 			type:"post",
	 			data:{name:name},
	 			async: false,
	 			url:url,
	 			success:function(data){
	 				var html="";
	 				if(data){
	 					for(var i=0;i<data.length;i++){
	 						var obj = data[i];
	 						html+=" <li class='' onclick='click_(event)' code='"+obj.code+"'>"+obj.code+"--"+obj.name+"</li>";
	 					}
	 				}
	 				$(_this).closest('.search_tip').find(".search_tip_list").html("").html(html)	
	 			}
	 		})
	     })	
	   //要操作选择的列表
	    $.each($(".search_tip_list li"),function(i,item){
	    	 $(item).on('mouseover',function(){
	    		 $(this).addClass('mouseOverCs');
	    	 })
	    	  $(item).on('mouseout',function(){
	    		 $(this).removeClass('mouseOverCs');
	    	 })
    	 })      
    	  
	})
	
    //弹框新增按钮事件
	function addlist(event){
		var target=$(event.target);
		$.each(target.closest('.search_tip').find(".search_tip_list").children("li"),function(i,item){
			if($(item).hasClass('select_color')){
	    		 $(item).removeClass("select_color");
	    		 $(item).clone(true);
	    		 $(item).remove();
	    		 target.closest('.search_tip').find(".search_tip_choicelist").append($(item));
	    		 //给新增的添加事件
	    		 $.each($(".search_tip_choicelist li"),function(i,item){
	    	    	 $(item).on('mouseover',function(){
	    	    		 $(this).addClass('mouseOverCs');
	    	    	 })
	    	    	  $(item).on('mouseout',function(){
	    	    		 $(this).removeClass('mouseOverCs');
	    	    	 })
	    	     })
	    	 }
   	    })  
	}
	  //弹框删除按钮事件
	function dellist(event){
		var target=$(event.target); 
		$.each(target.closest('.search_tip').find(".search_tip_choicelist li"),function(i,item){
	    	 if($(item).hasClass('select_color')){
	    		 $(item).removeClass("select_color");
	    		 $(item).clone(true);
	    		 $(item).remove();
	    		 target.closest('.search_tip').find(".search_tip_list").append($(item));
	    		//要操作选择的列表
	   	        $.each($(".search_tip_list li"),function(i,item){
	   	    	 $(item).on('mouseover',function(){
	   	    		 $(this).addClass('mouseOverCs');
	   	    	 })
	   	    	  $(item).on('mouseout',function(){
	   	    		 $(this).removeClass('mouseOverCs');
	   	    	 })
	       	 }) 
	    	 }
   	    })  
	}
	//点击事件  
	function click_(e){
		var target=e.target; 
		$(target).toggleClass('select_color');
	}
		
	//确认事件
	function btn_finish(event){
		var target=$(event.target);
		if(target.closest('.search_tip').find(".search_tip_choicelist li").length){
			var codeStr="";
			$.each(target.closest('.search_tip').find(".search_tip_choicelist li"),function(i,item){
				codeStr+=$(item).attr("code")+",";
			})
			codeStr=codeStr.substring(0,codeStr.length-1);
			target.closest('.td_box').find(".search_input").val("").val(codeStr);
			target.closest('.search_tip').find(".search_tip_list").html("");
			target.closest('.search_tip').find(".search_tip_choicelist").html("");
			target.closest('.search_tip').find(".search_tip_input").val("");
			target.closest('.search_tip').hide();
		}
		
	}
	//取消事件
	function btn_close(event){
		var target=$(event.target);
		target.closest('.search_tip').find(".search_tip_list").html("");
		target.closest('.search_tip').find(".search_tip_choicelist").html("");
		target.closest('.search_tip').find(".search_tip_input").val("");
		target.closest('.search_tip').hide();
	}
	
   function selectAll(){
		  $('input[name="outHospitalType"]').each(function(){  
	          //此处如果用attr，会出现第三次失效的情况  
	          $(this).prop("checked",true);  
	      });  
	}

	function disableAll(){
		  $('input[name="outHospitalType"]').each(function(){  
	          //此处如果用attr，会出现第三次失效的情况  
	          $(this).prop("checked",false);  
	      });  
	}
	
	
	//获取checkbox值
	function getFormVals(name){
		var arr = [];
		$("input[type='checkbox'][name='"+name+"']:checked").each(function(){
				arr.push($(this).val());	

		});
		return arr.toString();
	}
	
	function medicalRetire(pageNo,pageSize){
 		var outHospitalEndTime =$("#outHospitalEndTime").val();
		var outHospitalStartTime=$("#outHospitalStartTime").val();
		var officeId=$("#officeId").val();
		var operationName=$("#search_input1").val();
		var diseaseName=$("#search_input2").val();
		var diagnoseType=$("#diagnoseType").val();
		var inHospitalStatus=$("#inHospitalStatus").val();
		var outHospitalType=getFormVals("outHospitalType");
		if(!outHospitalEndTime && !outHospitalStartTime && !officeId && !operationName && !diseaseName && !diagnoseType && !inHospitalStatus && !outHospitalType){
			layer.alert("请至少输入一个查询条件!",{icon:5});
			return;
		}
		
		$.ajax({
			type:"post",
			url:"${basePath}/retrieval/clinicalRetrieval",
			data:{outHospitalEndTime:outHospitalEndTime,outHospitalStartTime:outHospitalStartTime,inHospitalStatus:inHospitalStatus,officeId:officeId,operationName:operationName,diseaseName:diseaseName,diagnoseType:diagnoseType,outHospitalType:outHospitalType,pageNo:pageNo,pageSize:pageSize},
			beforeSend:function(){
				$("#tbody").html("");
				$("#loading").show();
			},
			success:function(data){
				console.log(data);
				$("#loading").hide();
				if(data.success){
					var jsonMap=data.data.jsonList;
					var count=data.data.count;
					if(count>0){
						var html="";
						page(pageNo,count);
						for(var i=0;i<jsonMap.length;i++){
							var obj=jsonMap[i];
							html+="<tr>"+
							      "   <td class='tdLabel_5'>"+obj.mrId+"</td>"+
								  "	  <td class='tdLabel_5'>"+obj.name+"</td>"+
								  "   <td class='tdLabel_5'>"+obj.idNumber+"</td>"+
								  "   <td class='tdLabel_5'>"+obj.outHospitalDate+"</td>"+
								  "   <td class='tdLabel_5'>"+obj.outDeptName+"</td>"+
								  "	  <td class='tdLabel_5'>"+obj.outHospitalTypeName+"</td>"+
								  "   <td class='tdLabel_5'>"+
								  " 	<a class='int' target='_blank' href='${corePath}/medrecord/showMedrecordImage?firstGuid="+obj.firstGuid+"'>首页预览</a>"+
							      "     <a class='int' target='_blank' href='${corePath}/medrecord/medrecordHomePageManage?firstGuid="+obj.firstGuid+"'>首页编辑</a>"+
								      "</td>"
							      "</tr>"
						}
						$("#tbody").html(html);
					}else{
						layer.alert("暂无数据!",{icon:5});
						$("#tbody").html("");
						$("#totalPage").html(0);
			            $("#currentPage").html(0+"/"+0);
			            $('#page_plus').html("");
					}
				}
			}
		});
		
	}
	
	 function page(currentPage,totalCounts){
	        var pageSize = 10;
	        var visiblePages = 5;
	        var totalPages = Math.ceil(totalCounts/pageSize);
	        $('#page_plus').jqPaginator({

	            totalCounts: totalCounts,
	            pageSize:pageSize,
	            visiblePages: visiblePages,
	            currentPage: currentPage,

	            first:'<li class="first"><a href="javascript:void(0);">首页</a></li>',
	            prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
	            next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
	            last: '<li class="last"><a href="javascript:void(0);">末页</a></li>',
	            page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
	            onPageChange: function (num,type) {
	            	
	            	 if(type !='init'){
	                 
	            		 medicalRetire(num,pageSize);
	                 }
	            	
	                $("#totalPage").html(totalCounts);
	                $("#currentPage").html(num+"/"+totalPages);
	            }
	        });

	    }
		
</script>

</body>
</html> --%>